﻿using System;
using System.Collections.Generic;

namespace Util.TitleParser
{
    public sealed class Parser
    {
        private Parser()
        {
        }

        private static ITitleParser[] parsers = new ITitleParser[] { new Parse_SssEee(), new Parse_sxee(), new Parse_see() };


        public static Result ParseTitle(string title)
        {
            foreach (ITitleParser p in parsers)
            {
                try
                {
                    Result r = p.ParseTitle(title);
                    if (r.Name.Length != 0 && r.Details.Length != 0 && r.Season != 0 && r.Episode != 0)
                    {
                        return r;
                    }
                }
                catch (Exception)
                {
                }
            }
            throw new ArgumentException("Couldn't parse Title", "title");
        }
    }
}
